class BD_HUD extends HUD;

//varibles to hold texture images
var MaterialInstanceConstant M;

//varibles for console command use
var float NewScale;
var bool UseHud;
var bool GameHud;
var BD_PauseMenu		PauseMenuMovie;

//PostRender event draws to the screen every frame
simulated event PostRender( )
{
	super.PostRender();
	DisplayKismetMessages();
	
	if(UseHud)
	{	//draws the hud
		Draw();	
	}
}

function Draw()
{
	local float scale;
	local float max_scale;
	max_scale = 10;
	
	if( GameHud )
	{	//uses player health to determine how much scale to use in the vignette
		scale = BlackDeathHeroPawn(BlackDeathPawn(PlayerOwner.Pawn)).CalcCameraHealthRatio();
		scale = scale * max_scale;
	}
	else
	{	//use an scale declared by the console
		scale = NewScale;
	}
	
	M.SetScalarParameterValue('Vignette_Scale', scale);
}


exec function ShowMenu()
{
        // if using GFx HUD, use GFx pause menu
        TogglePauseMenu();
}
/*
 * Toggle the Pause Menu on or off.
 *
 */
function TogglePauseMenu()
{
    if ( PauseMenuMovie != none && PauseMenuMovie.bMovieIsOpen )
        {
        PauseMenuMovie.CloseMovie();
        }
        else
    {
        PlayerOwner.SetPause(True);
 
        if (PauseMenuMovie == None)
        {
            PauseMenuMovie = new class'BD_PauseMenu';
            PauseMenuMovie.MovieInfo = SwfMovie'BD_PauseMenu.BD_PauseMenu';
            PauseMenuMovie.bEnableGammaCorrection = FALSE;
                        PauseMenuMovie.LocalPlayerOwnerIndex = class'Engine'.static.GetEngine().GamePlayers.Find(LocalPlayer(PlayerOwner.Player));
            PauseMenuMovie.SetTimingMode(TM_Real);
        }
 
        //SetVisible(false);
        PauseMenuMovie.Start();
        //PauseMenuMovie.PlayOpenAnimation();
        PauseMenuMovie.AddFocusIgnoreKey('Escape');
    }
}
 
//UnPause and close Pause HUD SWF
function CompletePauseMenuClose()
{
    PlayerOwner.SetPause(False);
    PauseMenuMovie.Close(false);
}
 

exec function HUDSetScale( float scale )
{
	//keeps new scale in range of a valid scale value
	if(scale<0)
	{
		scale=0;
	}
	if(scale>10)
	{
		scale = 10;
	}
	
	//shows the scale that was set
	NewScale = scale;
	UseHud = true;
	GameHud = false;
	
}
exec function HUDToggle()
{
	//Toggles the hud on and off
	UseHud = !UseHud;
}
exec function HUDUseGameScale()
{
	//use the hud scale based on player health
	GameHud = true;
	UseHud = true;
}
defaultproperties
{
M=MaterialInstanceConstant'BD_FX.PostProcess.Health_Effect_Mat_INST';
NewScale = 2;
UseHud = true;
GameHud = true;
}
